package bsc.ejb.metadata;

import bsc.ejb.entity.Settings;
import java.io.Serializable;
import java.util.Collection;
import bsc.ejb.entity.Map;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

/**
 *
 * @author memozac
 */
@Entity
public class MapDrawing implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long idMapDrawing;

    @OneToOne
    private Map map;
    
    @ManyToOne
    private Framework framework;

    @Column(columnDefinition="text")
    private String name;
    @Column(columnDefinition="text")
    private String description;
    @Column(name="fileName", columnDefinition="text")
    private String file;

    @ManyToMany(targetEntity=Settings.class)
    @JoinTable(name="MapDrawingSettings",
    joinColumns=@JoinColumn(name="idMapDrawing"),
    inverseJoinColumns=@JoinColumn(name="idSettings"))
    private Collection<Settings> settings;

    public Map getMap() {
        return map;
    }

    public void setMap(Map map) {
        this.map = map;
    }

    public Framework getFramework() {
        return framework;
    }

    public void setFramework(Framework framework) {
        this.framework = framework;
    }

    public Long getIdMapDrawing() {
        return idMapDrawing;
    }

    public Collection<Settings> getSettings() {
        return settings;
    }

    public void setSettings(Collection<Settings> settings) {
        this.settings = settings;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMapDrawing != null ? idMapDrawing.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof MapDrawing)) {
            return false;
        }
        MapDrawing other = (MapDrawing) object;
        if ((this.idMapDrawing == null && other.idMapDrawing != null) || (this.idMapDrawing != null && !this.idMapDrawing.equals(other.idMapDrawing))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bsc.ejb.entity.MapDrawing[id=" + idMapDrawing + "]";
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the file
     */
    public String getFile() {
        return file;
    }

    /**
     * @param file the file to set
     */
    public void setFile(String file) {
        this.file = file;
    }

}//ends of class
